﻿using Microsoft.EntityFrameworkCore;
using Abp.Zero.EntityFrameworkCore;
using SOEI.Solution.Authorization.Roles;
using SOEI.Solution.Authorization.Users;
using SOEI.Solution.MultiTenancy;
using SOEI.Solution.EntityFrameworkCore.EntityMapper;
using System.Linq;
using E;
using SOEI.Solution.Integratedes.Organization;
using SOEI.Solution.Integratedes.ElectronicSignet;
using SOEI.Solution.DomainEntities.Organization;
using SOEI.Solution.EntityMapper;
using SOEI.Solution.DomainEntities.CustomerManagement;
using SOEI.Solution.DomainEntities.ContractManagement;
using SOEI.Solution.DomainEntities.PurQualificationAudit;
using SOEI.Solution.DomainEntities.RoomSourceVerifiyV1;
using SOEI.Solution.DomainEntities.TransactionManagement;
using SOEI.Solution.DomainEntities.RegulatoryMange;

namespace SOEI.Solution.EntityFrameworkCore
{
    /// <summary>
    /// 【SolutionDbContext扩展】综合系统中的老数据 DbSet
    /// </summary>
    public partial class SolutionDbContext 
    {

        #region ======================================== 经济机构 

        /// <summary> 
        /// 【综合系统的经济机构表】 经济机构表 /// 老系统
        /// </summary>
        public virtual DbSet<OEconomyOrgani> OEconomyOrganies { get; set; }

        /// <summary>
        /// 【综合系统的经济人员表】 经济人员表 /// 老系统
        /// </summary>
        public virtual DbSet<OEconomyPerson> OEconomyPersons { get; set; }

        /// <summary>
        /// 【综合系统的经济人员变更表】 经纪人员变更表 /// 老系统
        /// </summary>
        public virtual DbSet<OEconomyPersonChange> OEconomyPersonChanges { get; set; }

        /// <summary>
        /// 【综合系统的经济人员表】 机构管理员 /// 老系统
        /// </summary>
        public virtual DbSet<OEconomyAdmin> OEconomyAdmins { get; set; }

        /// <summary>
        /// 机构人员
        /// </summary>
        public virtual DbSet<OrganiPerson> OrganiPersons { get; set; }

        /// <summary>
        /// 机构人员注销表
        /// </summary>
        public virtual DbSet<OEconomyOrganiCancel> OEconomyOrganiCancellation { get; set; }

        #endregion

        #region ======================================== 交易合同相关

        /// <summary> 合同摘要 /// 老系统
        /// </summary>
        public virtual DbSet<ContractSummary> ContractSummarys { get; set; }

        /// <summary> 合同正文 /// 老系统
        /// </summary>
        public virtual DbSet<ContractBody> ContractBodys { get; set; }

        /// <summary> 合同状态 /// 老系统
        /// </summary>
        public virtual DbSet<ContractStatus> ContractStatus { get; set; }

        /// <summary> 合同双方 /// 老系统
        /// </summary>
        public virtual DbSet<ContractBoth> ContractBoths { get; set; }

        #endregion

        #region ======================================== 购资审核申请
        /// <summary>
        /// 老系统
        /// </summary>
        public virtual DbSet<PurQualificationApply> PurQualificationApplys { get; set; }
        /// 老系统
        public virtual DbSet<PurFamilyMember> PurFamilyMembers { get; set; }
        // 购房资格审查申请变更信息表 /// 老系统
        public virtual DbSet<PurQualificationChage> PurQualificationChages { get; set; }
        // 家庭成员信息变更表 /// 老系统
        public virtual DbSet<PurFamilyMemberChange> PurFamilyMemberChanges { get; set; }

        #endregion

        #region ======================================== 房源核验

        /// <summary>
        /// 房源核验
        /// </summary>
        public virtual DbSet<RoomVerifyV1> RoomVerifyV1s { get; set; }

        #endregion

        #region ======================================== 委托代理合同
        /// <summary>
        /// 委托代理合同摘要
        /// </summary>
        public virtual DbSet<CommissionContractDigest> CommissionContractDigests { get; set; }

        /// <summary>
        /// 委托代理合同正文
        /// </summary>
        public virtual DbSet<CommissionContractMainBody> CommissionContractMainBodys { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public virtual DbSet<TransactionManagement> TransactionManagements { get; set; }
        #endregion

        #region ======================================== 监管协议相关
        //（老系统）
        public virtual DbSet<Agreement> Agreements { get; set; }
        //（老系统）
        public virtual DbSet<AgreementState> AgreementStates { get; set; }
        //（老系统）
        public virtual DbSet<SuperviseBank> SuperviseBanks { get; set; }
        //（老系统）
        public virtual DbSet<Regulator> Regulators { get; set; }
        //（老系统）
        public virtual DbSet<RegulatoryAccount> RegulatoryAccounts { get; set; }
        //（老系统）
        public virtual DbSet<AgreementChange> AgreementChanges { get; set; }
        //（老系统）
        public virtual DbSet<AgreementNumber> AgreementNumbers { get; set; }
        //（老系统）
        public virtual DbSet<AgreementBoth> AgreementBoths { get; set; }
        //（老系统）
        public virtual DbSet<PropertyCard> PropertyCards { get; set; }
        //（老系统）
        public virtual DbSet<Located> Locateds { get; set; }
        //（老系统）
        public virtual DbSet<House> Houses { get; set; }
        //（老系统）视图
        public virtual DbSet<ViewAgreement> ViewAgreements { get; set; }


        #endregion

        #region ======================================== 其他类型

        /// <summary>
        /// 证照上传（老系统）
        /// </summary>
        public virtual DbSet<LicensesUpload> LicensesUploads { get; set; }

        #endregion

        /// <summary>
        ///  配置用户表
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected void SetOldUserTablePrefix(ModelBuilder modelBuilder)
        {
            #region 经济机构
            modelBuilder.ApplyConfiguration(new OEconomyOrganiMapper());
            modelBuilder.ApplyConfiguration(new OEconomyPersonMapper());
            modelBuilder.ApplyConfiguration(new OEconomyPersonChangeMapper());
            modelBuilder.ApplyConfiguration(new OEconomyAdminMapper());
            modelBuilder.ApplyConfiguration(new OEconomyOrganiCancelMapper());
            #endregion

            #region 交易合同相关

            modelBuilder.ApplyConfiguration(new ContractSummaryMapper()); // 合同统计

            modelBuilder.ApplyConfiguration(new ContractBodyMapper());  // 合同正文

            modelBuilder.ApplyConfiguration(new ContractStatusMapper()); // 合同状态

            modelBuilder.ApplyConfiguration(new ContractBothMapper()); // 合同状态


            #endregion

            #region 购资审核申请

            modelBuilder.ApplyConfiguration(new PurQualificationApplyMapper());

            modelBuilder.ApplyConfiguration(new PurFamilyMemberMapper());

            modelBuilder.ApplyConfiguration(new PurQualificationChageMapper());

            modelBuilder.ApplyConfiguration(new PurFamilyMemberChangeMapper());
            
            #endregion

            #region 房源核验

            modelBuilder.ApplyConfiguration(new RoomVerifyV1Mapper()); 

            #endregion

            #region 委托代理合同

            modelBuilder.ApplyConfiguration(new CommissionContractDigestMapper());

            modelBuilder.ApplyConfiguration(new CommissionContractMainBodyMapper());

            modelBuilder.ApplyConfiguration(new TransactionManagementMapper());

            #endregion

            #region 监管协议相关

            modelBuilder.ApplyConfiguration(new AgreementMapper());
            modelBuilder.ApplyConfiguration(new AgreementStateMapper());
            modelBuilder.ApplyConfiguration(new SuperviseBankMapper());
            modelBuilder.ApplyConfiguration(new RegulatorMapper());
            modelBuilder.ApplyConfiguration(new RegulatoryAccountMapper());
            modelBuilder.ApplyConfiguration(new AgreementChangeMapper());
            modelBuilder.ApplyConfiguration(new AgreementNumberMapper());
            modelBuilder.ApplyConfiguration(new AgreementBothMapper());
            modelBuilder.ApplyConfiguration(new PropertyCardMapper());
            modelBuilder.ApplyConfiguration(new LocatedMapper());
            modelBuilder.ApplyConfiguration(new HouseMapper());
            modelBuilder.ApplyConfiguration(new ViewAgreementMapper());

            #endregion

            #region 其他类型

            modelBuilder.ApplyConfiguration(new LicensesUploadMapper());

            #endregion
        }
    }
}
